<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
	<meta charset="UTF-8">
	<title>添加办公楼</title>
	<meta name="renderer" content="webkit">	
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">	
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">	
	<meta name="apple-mobile-web-app-status-bar-style" content="black">	
	<meta name="apple-mobile-web-app-capable" content="yes">	
	<meta name="format-detection" content="telephone=no">	
	<link rel="stylesheet" type="text/css" th:href="@{/static/common/layui/css/layui.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/static/common/bootstrap/css/bootstrap.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/static/common/global.css}" media="all">
	<link rel="stylesheet" type="text/css" th:href="@{/static/css/personal.css}" media="all">
</head>
<body>
<section class="layui-larry-box">
	<div class="larry-personal">
		<header class="larry-personal-tit">
			<span>添加游戏角色</span>
			<div class="layui-inline">
				<a href="/mapmanagement/map/upload/office/room/page" class="refresh refreshThis"><i class="layui-icon">&#x1002;</i> 刷新</a>
			</div>
		</header><!-- /header -->
		<div class="larry-personal-body clearfix">
			<form class="layui-form col-lg-5" action="" method="post">
				<div class="layui-form-item">
					<label class="layui-form-label">角色名称</label>
					<div class="layui-input-block">
						<input type="text" lay-verify="required" id="roomName" placeholder="请输入" name="roomName" autocomplete="off" class="layui-input">
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">选择游戏大区</label>
					<div class="layui-input-block">
						<select id="officeId" name="officeId" lay-filter="aihao">
							<option th:each="item,stat : ${list}" th:value="${item.id}" th:text="${item.areaName}"></option>
						</select>
					</div>
				</div>

				<div class="layui-form-item">
					<label class="layui-form-label">选择所属账号</label>
					<div class="layui-input-block">
						<select id="userId" name="userId" lay-filter="aihao">
							<option th:each="item,stat : ${userList}" th:value="${item.id}" th:text="${item.nickName}"></option>
						</select>
					</div>
				</div>



				<div id="submit_btn_div" class="layui-form-item">
					<div class="layui-input-block">
						<button id="submit_btn" type="button" class="layui-btn">立即提交</button>
						<button id="clear_btn" type="reset" class="layui-btn layui-btn-primary">重置</button>
					</div>
				</div>

			</form>
		</div>
	</div>
</section>
<script type="text/javascript" th:src="@{/static/js/jquery-1.9.1.min.js}"></script>
<script type="text/javascript" th:src="@{/static/common/layui/layui.js}"></script>
<script type="text/javascript" th:src="@{/static/js/wangEditor.min.js}"></script>
<script type="text/javascript">
	layui.use(['form','upload','layedit','jquery','layer'],function(){
        var $ = layui.$;
        var layer = layui.layer;

        $("#tag_add").on("click",function () {
			var html = '<div class="layui-inline">' +
                '<div class="layui-input-inline">' +
                '<input type="text" name="tagInfo" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">' +
                '</div>' +
                '</div>';
			$("#tag_btn_div").before(html);
        });

        $(".refresh").on("click",function () {
            window.location.href="/mapmanagement/map/upload/office/room/page";
        });


        $("#submit_btn").on("click",function () {
            //提交按钮
            var roomName = $("#roomName").val();
            var officeId = $("#officeId").val();
            var tagInfo = [];
            $("input[name='tagInfo']").each(function () {
				tagInfo.push($(this).val());
            });
            $.ajax({
                url:"/mapmanagement/map/officeRoomInfos/save",
                data:{
                    "roomName":roomName,
                    "officeId":officeId,
                    "tagInfo":tagInfo
                },
                method:'post',
                dataType:'json',
                traditional:true,
                success: function (data) {
                    console.log(data);
                    if (data.code == 500){
                        layer.alert(data.msg, function () {
                            layer.close(layer.index);
                        });
					} else {
                        layer.alert(data.msg, function () {
                            layer.close(layer.index);
                            window.location.reload();
                        });
					}
                },
                error:function () {
                    layer.alert("办公楼房间信息上传失败", function () {
                        layer.close(layer.index);
                    });
                }
            })
        });
	});



</script>
</body>
</html>